home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 32 / dui.zip / KEYBOARD.INC < prev   
Text File  |  1986-12-28  |  2KB  |  65 lines

  1. {
  2.                          ---- K E Y B O A R D ----
  3.  
  4. These routines will let you detect, and control, the various shift states of
  5. the stardard PC keyboard (I don't know if they work on an AT, JR, or clone).
  6.  
  7. The function "KeyChk" will check the state of the specified key, and return
  8. either TRUE of FALSE. The procedure "KeySet" will accept a key, and a state
  9. (TRUE or FALSE), and will set the key to that state.
  10.  
  11. The key definitions are as follows:
  12.  
  13.    LshDep - Is the left shift key depressed?
  14.    RshDep - Is the right shift key depressed?
  15.    CtlDep - Is the CTRL key depressed?
  16.    AltDep - Is the ALT key depressed?
  17.    ScrDep - Is ScrollLock depressed?       ScrLok - Are we in ScrollLock state?
  18.    NumDep - Is NumLock depressed?          NumLok - Are we in NumLock state?
  19.    CapDep - Is CapsLock depressed?         CapLok - Are we in CapsLock state?
  20.    InsDep - Is Insert depressed?           InsMod - Are we in Insert mode?
  21.  
  22. All states are checkable, but only the "___Lok" states can be meaningfully
  23. set; I don't know what happens if you try to set a "___Dep" state (Norton
  24. says it's "potentially very disruptive" to do so...)
  25.  
  26.                        --------- Examples ---------
  27.  
  28. Suppose we want to make the PC work like a standard typewriter, such that
  29. if you press a SHIFT key, it turns off CapsLock. Just insert the following
  30. code at some point where it will execute fairly often:
  31.  
  32.     If (KeyChk(LshDep) or KeyChk(RshDep)) and KeyChk(CapLok)
  33.        Then KeySet(CapLok, False);
  34.  
  35. Or, suppose we just want to harass those people who leave the keyboard in
  36. NUMLOCK state. How's this for user-hostile software:
  37.  
  38.     If KeyChk(NumLok)
  39.        Then Sound(50+Random(800))
  40.        Else NoSound;
  41.  
  42. Makes it sound like you've got hornets in your hard disk!
  43.  
  44. -------------------------------------------------------------------------------
  45.                     Public Domain, Mark VanTassel, 9/11/86
  46. -------------------------------------------------------------------------------
  47. }
  48.  
  49. Type  K_Type=(RshDep, LshDep, CtlDep, AltDep, ScrLok ,NumLok ,CapLok, InsMod,
  50.               Kjunk1, Kjunk2, Kjunk3, Kjunk4, ScrDep, NumDep, CapDep, InsDep);
  51. Var   K_Bits:Set of K_Type Absolute $0000:$0417;
  52.  
  53.  
  54. Procedure KeySet(Key:K_Type; TF:Boolean);
  55. Begin
  56.      If TF
  57.         Then K_Bits := K_Bits + [Key]
  58.         Else K_Bits := K_Bits - [Key];
  59. End;
  60.  
  61. Function KeyChk(Key:K_Type):Boolean;
  62. Begin
  63.      KeyChk := Key in K_Bits;
  64. End;
  65.